// pages/Class_Schedule/Class_Schedule.js
const app = getApp();
var config = app.globalData.config;
const {
	get
} = require('../../utils/http.js');
const http = require('../../utils/http.js');
Page({
	onReady() {
		if (!app.login()) {
			return;
		}
	},
	data: {
		dateString: "",
		spot: ['2022/9/8', '2022/9/12', '2022/9/14', '2022/9/15', '2022/10/17'],
		show: false,
		defaultDate: '',
		courseList: []
	},
	dateChange(e) {
		this.setData({
			dateString: e.detail.dateString
		});
		
		this.getMyCourse(e.detail.dateString);	//根据日期选择我的课程
	},
	toToday() {
		let year = new Date().getFullYear(),
			month = new Date().getMonth() + 1,
			day = new Date().getDate();
		this.setData({
			year,
			day,
			month
		})
	},
	onLoad: function() {
		this.toToday();
		var _notTime = this.data.year + '-' + this.data.month + '-' + this.data.day;
		this.getMyCourse(_notTime);
		
		this.getMyCourseDateList();
	},
	getMyCourse(_notTime) {
		var that = this;
		http.httpPost(config.getTodayCourse, {
			classdatetime: _notTime
		}, function(e) {
			if (e.code == 1) {
				// console.log(e);
				that.setData({
					'courseList': e.data
				});
			} else {

			}

		});
	},
	getMyCourseDateList(){
		var that = this;
		http.httpPost(config.getMyCourseDateList, {
		}, function(e) {
			if (e.code == 1) {
				// console.log(e);
				that.setData({
					'spot': e.data
				});
			} else {
		
			}
		
		});
	}

})
